<template>
  <div>
    <el-dialog class="dialog" title="版本记录" :visible.sync="dialogVisible">
      <el-row style="margin-bottom: 15px">
        <el-col :span="12">
          <p>创建人：{{createUser}}</p>
        </el-col>
        <el-col :span="12">
          <p>创建时间：{{createTime}}</p>
        </el-col>
      </el-row>
      <el-table class="table" v-loading="loading" :data="list" border>
        <el-table-column prop="lastUpdateUser" label="最后修改人"></el-table-column>
        <el-table-column label="动作">
          <template slot-scope="scope">
            <span v-show="scope.row.operate == 1">变更</span>
            <span v-show="scope.row.operate == 2">发布</span>
          </template>
        </el-table-column>
        <el-table-column prop="lastUpdateTime" label="最后修改时间"></el-table-column>
      </el-table>
      <div style="text-align: right;padding-top: 15px;">
        <el-pagination layout="total,prev, pager, next"
                       :current-page.sync="currentPage"
                       :total="page.total" :page-size="10" @current-change="handleCurrentChange"/>
      </div>
      <!--<span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleMakesure">确 定</el-button>
      </span>-->
    </el-dialog>
  </div>


</template>

<script type="text/babel">
  import { version } from '@/service/getData'

export default {
    data () {
      return {
        msg: 'version',
        loading: false,
        dialogVisible: false,
        createUser: '',
        createTime: '',
        list: [],
        page: {
          current: 1,
          pages: 1,
          size: 10,
          total: 0
        },
        currentPage: 1
      }
    },
    computed: {},
    methods: {
      axiosVersion (payload) {
        this.loading = true
        version(payload)
          .then((res) => {
            console.log(res)
            if (res.data && 'code' in res.data && res.data.code === 1) {
              var resJson = res.data
              this.list = resJson.data.list
              this.page = resJson.data.page
              this.createTime = resJson.data.createTime
              this.createUser = resJson.data.createUser
            }
          })
          .finally(() => {
            this.loading = false
          })
      },
      init () {
        this.dialogVisible = true
        this.currentPage !== 1 ? this.currentPage = 1 : this.handleCurrentChange()
      },
      handleCurrentChange () {
        this.axiosVersion({
          'logicId': this.$route.params.id,   // 微页面ID
          'page': this.currentPage, // 当前页
          'size': 10 // 分页条数
        })
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss" rel="stylesheet/scss">

</style>
